package com.foomia.truego.types;



import com.foomia.truegoed.util.ParcelUtils;

import android.os.Parcel;
import android.os.Parcelable;

public class Tip implements TruegoType,Parcelable{
	private String mCreated;
    private String mDistance;
    private String mId;
    private Tip.Stats mStats;
    private String mStatus;
    private String mText;
    private User mUser;
    private Venue mVenue;
    
    private String mShop;
    private String mAddr;
    private String mTel;
    private String mLng;
    private String mLat;
    private String mTitle;
    private String mPhoto;


    public Tip() {
    }

    private Tip(Parcel in) {
        mCreated = ParcelUtils.readStringFromParcel(in);
        mDistance = ParcelUtils.readStringFromParcel(in);
        mId = ParcelUtils.readStringFromParcel(in);
        
        if (in.readInt() == 1) {
            mStats = in.readParcelable(Tip.Stats.class.getClassLoader());
        }
        
        mStatus = ParcelUtils.readStringFromParcel(in);
        mText = ParcelUtils.readStringFromParcel(in);
        
        if (in.readInt() == 1) {
            mUser = in.readParcelable(User.class.getClassLoader());
        }
        
        if (in.readInt() == 1) {
            mVenue = in.readParcelable(Venue.class.getClassLoader());
        }
        
        mShop = ParcelUtils.readStringFromParcel(in);
        mAddr = ParcelUtils.readStringFromParcel(in);
        mTel = ParcelUtils.readStringFromParcel(in);
        mLng = ParcelUtils.readStringFromParcel(in);
        mLat = ParcelUtils.readStringFromParcel(in);
        mTitle = ParcelUtils.readStringFromParcel(in);
        mPhoto = ParcelUtils.readStringFromParcel(in);
    }
    
    public static final Parcelable.Creator<Tip> CREATOR = new Parcelable.Creator<Tip>() {
        public Tip createFromParcel(Parcel in) {
            return new Tip(in);
        }

        @Override
        public Tip[] newArray(int size) {
            return new Tip[size];
        }
    };
    
    public String getCreated() {
        return mCreated;
    }

    public void setCreated(String created) {
        mCreated = created;
    }

    public String getDistance() {
        return mDistance;
    }

    public void setDistance(String distance) {
        mDistance = distance;
    }

    public String getId() {
        return mId;
    }

    public void setId(String id) {
        mId = id;
    }
    
    public Tip.Stats getStats() {
        return mStats;
    }
    
    public void setStats(Tip.Stats stats) {
        mStats = stats;
    }
    
    public String getStatus() {
        return mStatus;
    }
    
    public void setStatus(String status) {
        mStatus = status;
    }

    public String getText() {
        return mText;
    }

    public void setText(String text) {
        mText = text;
    }

    public User getUser() {
        return mUser;
    }

    public void setUser(User user) {
        mUser = user;
    }

    public Venue getVenue() {
        return mVenue;
    }

    public void setVenue(Venue venue) {
        mVenue = venue;
    }
    
    
    public String getShop() {
        return mShop;
    }

    public void setShop(String shop) {
    	mShop = shop;
    }
    
    public String getAddr() {
        return mAddr;
    }

    public void setAddr(String addr) {
    	mAddr = addr;
    }
    
    public String getTel() {
        return mTel;
    }

    public void setTel(String tel) {
    	mTel = tel;
    }
    
    public String getLng() {
        return mLng;
    }

    public void setLng(String lng) {
    	mLng = lng;
    }
    
    public String getLat() {
        return mLat;
    }

    public void setLat(String lat) {
    	mLat = lat;
    }
    
    public String getTitle() {
        return mTitle;
    }

    public void setTitle(String title) {
    	mTitle = title;
    }
    
    public String getPhoto() {
        return mPhoto;
    }

    public void setPhoto(String photo) {
    	mPhoto = photo;
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        ParcelUtils.writeStringToParcel(out, mCreated);
        ParcelUtils.writeStringToParcel(out, mDistance);
        ParcelUtils.writeStringToParcel(out, mId);
        
        if (mStats != null) {
            out.writeInt(1);
            out.writeParcelable(mStats, flags);
        } else {
            out.writeInt(0);
        }

        ParcelUtils.writeStringToParcel(out, mStatus);
        ParcelUtils.writeStringToParcel(out, mText);
        
        if (mUser != null) {
            out.writeInt(1); 
            out.writeParcelable(mUser, flags);
        } else {
            out.writeInt(0);
        }
         
        if (mVenue != null) {
            out.writeInt(1);
            out.writeParcelable(mVenue, flags);
        } else {
            out.writeInt(0);
        }
        
        ParcelUtils.writeStringToParcel(out, mShop);
        ParcelUtils.writeStringToParcel(out, mAddr);
        ParcelUtils.writeStringToParcel(out, mTel);
        ParcelUtils.writeStringToParcel(out, mLng);
        ParcelUtils.writeStringToParcel(out, mLat);
        ParcelUtils.writeStringToParcel(out, mTitle);
        ParcelUtils.writeStringToParcel(out, mPhoto);
    }

    @Override
    public int describeContents() {
        return 0;
    }
    
    
    public static class Stats implements TruegoType, Parcelable {

        private int mDoneCount;
        private int mTodoCount;
        
        public Stats() {
        }

        private Stats(Parcel in) {
            mDoneCount = in.readInt();
            mTodoCount = in.readInt();
        }
        
        public static final Parcelable.Creator<Tip.Stats> CREATOR = new Parcelable.Creator<Tip.Stats>() {
            public Tip.Stats createFromParcel(Parcel in) {
                return new Tip.Stats(in);
            }

            @Override
            public Tip.Stats[] newArray(int size) {
                return new Tip.Stats[size];
            }
        };
        
        public int getDoneCount() {
            return mDoneCount;
        }
        
        public void setDoneCount(int doneCount) {
            mDoneCount = doneCount;
        }
        
        public int getTodoCount() {
            return mTodoCount;
        }
        
        public void setTodoCount(int todoCount) {
            mTodoCount = todoCount;
        }

        @Override
        public void writeToParcel(Parcel out, int flags) {
            out.writeInt(mDoneCount);
            out.writeInt(mTodoCount);
        }

        @Override
        public int describeContents() {
            return 0;
        }
    }
    
    public static class Status implements TruegoType, Parcelable {

        private int mDone;
        private int mTodo;
        
        public Status() {
        }

        private Status(Parcel in) {
            mDone = in.readInt();
            mTodo = in.readInt();
        }
        
        public static final Parcelable.Creator<Tip.Status> CREATOR = new Parcelable.Creator<Tip.Status>() {
            public Tip.Status createFromParcel(Parcel in) {
                return new Tip.Status(in);
            }

            @Override
            public Tip.Status[] newArray(int size) {
                return new Tip.Status[size];
            }
        };
        
        public int getDone() {
            return mDone;
        }
        
        public void setDone(int done) {
            mDone = done;
        }
        
        public int getTodo() {
            return mTodo;
        }
        
        public void setTodo(int todo) {
            mTodo = todo;
        }

        @Override
        public void writeToParcel(Parcel out, int flags) {
            out.writeInt(mDone);
            out.writeInt(mTodo);
        }

        @Override
        public int describeContents() {
            return 0;
        }
    }

}
